public class Room {
    private int num;//房间
    private String type;//房型
    private boolean state;//状态

    public int getNum() {
        return num;
    }


    public void setNum(int num) {
        this.num = num;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean getState() {
        return state;
    }

    public void setState(boolean state) {
        this.state = state;
    }

    public Room(int num, String type, boolean state) {
        this.num = num;
        this.type = type;
        this.state = state;
    }

    public Room() {
    }
    public String toString() {//返回房间对象的信息
        return "["+num+","+type+","+(state ? "空闲" :"占用")+"]";

    }
//测试重写toString
    /*public static void main(String[] args) {
        Room room = new Room(101,"单人间",false);
        System.out.println(room);
        }
        */

    public boolean equals(Object obj) {//如果两个房间的房间号相等那么说明房间相同返回值为true 否则false
        if(obj == null || (obj instanceof Room)){return false;}
        if(obj == this) {return true;}

        Room room = (Room) obj;
        return room.getNum() == this.getNum();
    }

}
